<? include ('../includes/functions.php'); ?>
<?
ob_start();
connectdb();
global $con;

//Post Params
$name = $_POST['name'];
$employee_number = $_POST['employee_number'];
$department = $_POST['department'];
$designation = $_POST['designation'];
$nic = $_POST['nic'];
$gender = $_POST['gender'];
$date_of_birth = $_POST['date_of_birth'];
$password_plain = $_POST['password_hash'];

$password_hash = sha1($password_plain);

//INSERT
$query = " INSERT INTO employee (  name, employee_number, department, designation, nic, gender, date_of_birth, password_hash )  VALUES (  '$name', '$employee_number', '$department', '$designation', '$nic', '$gender', '$date_of_birth', '$password_hash' ) ";
$result = mysqli_query($con, $query);

if ($result) {
    $_SESSION["infomessage"] = "Signup Successful!";
    echo 'Success';
} else {
    $_SESSION["errormessage"] = "Signup Failed!";
    echo 'Query Failed';
}
header("Location: /login");
ob_end_flush();
?>